<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE Trustworthy          #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE NoImplicitPrelude    #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# LANGUAGE CPP                  #-}</span><span>
</span><span id="line-4"></span><span class="hs-comment">-- Whether there are identities depends on the platform</span><span>
</span><span id="line-5"></span><span class="hs-pragma">{-# OPTIONS_HADDOCK hide #-}</span><span>
</span><span id="line-6"></span><span>
</span><span id="line-7"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- Module      :  GHC.IO.Windows.Paths</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- Copyright   :  (c) The University of Glasgow, 2017</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- License     :  see libraries/base/LICENSE</span><span>
</span><span id="line-12"></span><span class="hs-comment">--</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- Maintainer  :  libraries@haskell.org</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- Stability   :  internal</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- Portability :  non-portable</span><span>
</span><span id="line-16"></span><span class="hs-comment">--</span><span>
</span><span id="line-17"></span><span class="hs-comment">-- Windows FilePath handling utility for GHC code.</span><span>
</span><span id="line-18"></span><span class="hs-comment">--</span><span>
</span><span id="line-19"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-20"></span><span>
</span><span id="line-21"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.IO.Windows.Paths</span><span>
</span><span id="line-22"></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Windows.Paths.html#getDevicePath"><span class="hs-identifier">getDevicePath</span></a></span><span>
</span><span id="line-23"></span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;windows_cconv.h&quot;
</span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Base.html"><span class="hs-identifier">GHC.Base</span></a></span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.html"><span class="hs-identifier">GHC.IO</span></a></span><span>
</span><span id="line-29"></span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.C.String.html"><span class="hs-identifier">Foreign.C.String</span></a></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.Marshal.Alloc.html"><span class="hs-identifier">Foreign.Marshal.Alloc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Foreign.Marshal.Alloc.html#free"><span class="hs-identifier">free</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-32"></span><span>
</span><span id="line-33"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">safe</span><span> </span><span class="hs-string">&quot;__hs_create_device_name&quot;</span><span>
</span><span id="line-34"></span><span>    </span><span id="c_GetDevicePath"><span class="annot"><a href="GHC.IO.Windows.Paths.html#c_GetDevicePath"><span class="hs-identifier hs-var">c_GetDevicePath</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.C.String.html#CWString"><span class="hs-identifier hs-type">CWString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Foreign.C.String.html#CWString"><span class="hs-identifier hs-type">CWString</span></a></span><span>
</span><span id="line-35"></span><span>
</span><span id="line-36"></span><span class="hs-comment">-- | This function converts Windows paths between namespaces. More specifically</span><span>
</span><span id="line-37"></span><span class="hs-comment">-- It converts an explorer style path into a NT or Win32 namespace.</span><span>
</span><span id="line-38"></span><span class="hs-comment">-- This has several caveats but they are caviats that are native to Windows and</span><span>
</span><span id="line-39"></span><span class="hs-comment">-- not POSIX. See</span><span>
</span><span id="line-40"></span><span class="hs-comment">-- https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247.aspx.</span><span>
</span><span id="line-41"></span><span class="hs-comment">-- Anything else such as raw device paths we leave untouched.  The main benefit</span><span>
</span><span id="line-42"></span><span class="hs-comment">-- of doing any of this is that we can break the MAX_PATH restriction and also</span><span>
</span><span id="line-43"></span><span class="hs-comment">-- access raw handles that we couldn't before.</span><span>
</span><span id="line-44"></span><span class="annot"><a href="GHC.IO.Windows.Paths.html#getDevicePath"><span class="hs-identifier hs-type">getDevicePath</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>
</span><span id="line-45"></span><span id="getDevicePath"><span class="annot"><span class="annottext">getDevicePath :: FilePath -&gt; IO FilePath
</span><a href="GHC.IO.Windows.Paths.html#getDevicePath"><span class="hs-identifier hs-var hs-var">getDevicePath</span></a></span></span><span> </span><span id="local-6989586621679544282"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679544282"><span class="hs-identifier hs-var">path</span></a></span></span><span>
</span><span id="line-46"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621679544281"><span class="annot"><span class="annottext">CWString
</span><a href="#local-6989586621679544281"><span class="hs-identifier hs-var">str</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; (CWString -&gt; IO CWString) -&gt; IO CWString
forall a. FilePath -&gt; (CWString -&gt; IO a) -&gt; IO a
</span><a href="Foreign.C.String.html#withCWString"><span class="hs-identifier hs-var">withCWString</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679544282"><span class="hs-identifier hs-var">path</span></a></span><span> </span><span class="annot"><span class="annottext">CWString -&gt; IO CWString
</span><a href="GHC.IO.Windows.Paths.html#c_GetDevicePath"><span class="hs-identifier hs-var">c_GetDevicePath</span></a></span><span>
</span><span id="line-47"></span><span>       </span><span id="local-6989586621679544279"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679544279"><span class="hs-identifier hs-var">newPath</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CWString -&gt; IO FilePath
</span><a href="Foreign.C.String.html#peekCWString"><span class="hs-identifier hs-var">peekCWString</span></a></span><span> </span><span class="annot"><span class="annottext">CWString
</span><a href="#local-6989586621679544281"><span class="hs-identifier hs-var">str</span></a></span><span>
</span><span id="line-48"></span><span>       </span><span class="annot"><span class="annottext">CWString -&gt; IO ()
forall a. Ptr a -&gt; IO ()
</span><a href="Foreign.Marshal.Alloc.html#free"><span class="hs-identifier hs-var">free</span></a></span><span> </span><span class="annot"><span class="annottext">CWString
</span><a href="#local-6989586621679544281"><span class="hs-identifier hs-var">str</span></a></span><span>
</span><span id="line-49"></span><span>       </span><span class="annot"><span class="annottext">FilePath -&gt; IO FilePath
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679544279"><span class="hs-identifier hs-var">newPath</span></a></span><span>
</span><span id="line-50"></span></pre></body></html>